(function($){
	var _submit = function(method,url,data,target){
		var formId = "__form__";
	    var $form = $("#"+formId);
	    if ($form.length==0) {  //create form
	        $form = $(document.createElement('form'));
	        $form.attr("id",formId);
	        $form.hide();
	        $form.appendTo($("body"));
	    }
	    $form.empty();
        $form.attr("method",method);
        if(url.indexOf("?")!=-1){
        	var urlArr = url.split("?");
        	var paramStr = urlArr[1];
        	url = urlArr[0];
        	var paramArr = paramStr.split("&");
        	for(var i in paramArr){
        		var key="";
        		var value="";
        		var param = paramArr[i].trim();
        		if(param!=""){
        			if(param.indexOf("=")==-1){
        				key = param;
        			}else{
        				var kvArr = param.split("="); 
        				key = kvArr[0].trim();
        				value = kvArr[1].trim(0);
        			}
        			key = decodeURIComponent(key);
        			value = decodeURIComponent(value);
    	    		var $input = $(document.createElement('input'));
    	    		$input.attr("type","hidden");
    	    		$input.attr("name",key);
    	    		$input.val(value);
    	    		$input.appendTo($form);
        		}
        	}
        	
        }
        
        $form.attr("action",url);
        if(target==null){
        	target="_blank";
        }
        $form.attr("target",target);
	    if ($.isPlainObject(data)) {
	    	$.map(data,function(value, key){
	    		var $input = $(document.createElement('input'));
	    		$input.attr("type","hidden");
	    		$input.attr("name",key);
	    		$input.val(value);
	    		$input.appendTo($form);
	    	});
	    }
	    $form.submit();
	};
	$.extend({
		"submit":{
			"get":function(url,data,target){
				_submit("GET",url,data,target);
			},
			"post":function(url,data,target){
				_submit("POST",url,data,target);
			},
			"put":function(url,data,target){
				_submit("PUT",url,data,target);
			},
			"delete":function(url,data,target){
				_submit("DELETE",url,data,target);
			},
		}
		
	});
})(jQuery);